/*      */ package com.qmsk.business.bussBill.bussBill.controller;
/*      */ 
/*      */ import com.qmsk.business.bussBill.bussBill.dao.BussBillDao;
/*      */ import com.qmsk.business.bussBill.pbPaid.PbPaid;
/*      */ import com.qmsk.business.member.bussbilldisctcouponpay.dao.BussBillDisctCouPonPayDao;
/*      */ import com.qmsk.business.member.bussbillpaycheck.dao.BussBillPayCheckDao;
/*      */ import com.qmsk.business.member.bussbillpaypos.dao.BussBillPayPosDAO;
/*      */ import com.qmsk.business.member.custSMS.bean.CustMessage;
/*      */ import com.qmsk.business.member.member.dao.MemberDAO;
/*      */ import com.qmsk.business.member.memberAct.MemberActConst;
/*      */ import com.qmsk.business.member.memberCashCoupConsumeRecord.dao.MemberCashCouponConsumeRecordDAO;
/*      */ import com.qmsk.business.member.memberCashCoupDetail.dao.MemberCashCouponDetailDAO;
/*      */ import com.qmsk.business.member.memberIntegralConsumeRecord.dao.MemberIntegralConsumeRecordDAO;
/*      */ import com.qmsk.business.member.memberIntegralDetail.dao.MemberIntegralDetailDAO;
/*      */ import com.qmsk.business.member.memberLog.dao.MemberLogDAO;
/*      */ import com.qmsk.session.UserSessionInfo;
/*      */ import com.qmsk.session.bean.CSessionUser;
/*      */ import com.utils.basic.MapUtils;
/*      */ import com.utils.basic.ObjectComm;
/*      */ import com.utils.gson.in.GsonHeadManyRows;
/*      */ import com.utils.gson.in.GsonHeadOneRow;
/*      */ import com.utils.gson.in.ParserDataSetJson;
/*      */ import com.utils.gson.out.GsonEbRst;
/*      */ import com.utils.http.HttpGsonPtResponseUtils;
/*      */ import com.utils.jdbc.connection.DbConnection;
/*      */ import com.utils.web.RequestUtils;
/*      */ import com.utils.web.ResponseUtils;
/*      */ import java.sql.SQLException;
/*      */ import java.util.Date;
/*      */ import java.util.HashMap;
/*      */ import java.util.List;
/*      */ import java.util.Map;
/*      */ import javax.servlet.http.HttpServletRequest;
/*      */ import javax.servlet.http.HttpServletResponse;
/*      */ import org.apache.commons.lang.StringUtils;
/*      */ import org.apache.log4j.Logger;
/*      */ import org.springframework.beans.factory.annotation.Autowired;
/*      */ import org.springframework.stereotype.Controller;
/*      */ import org.springframework.transaction.annotation.Transactional;
/*      */ import org.springframework.web.bind.annotation.PathVariable;
/*      */ import org.springframework.web.bind.annotation.RequestMapping;
/*      */ 
/*      */ @Controller
/*      */ @RequestMapping({"bussBill"})
/*      */ public class BussBillController
/*      */ {
/*   51 */   private static final Logger logger = Logger.getLogger(BussBillController.class);
/*      */ 
/*      */   @Autowired
/*      */   private MemberIntegralDetailDAO integralDetailDAO;
/*      */ 
/*      */   @Autowired
/*      */   private MemberLogDAO memberLogDAO;
/*      */ 
/*      */   @Autowired
/*      */   private MemberDAO memberDAO;
/*      */ 
/*      */   @Autowired
/*      */   private MemberIntegralConsumeRecordDAO integralConsumeRecordDAO;
/*      */ 
/*      */   @Autowired
/*      */   private BussBillDao dao;
/*      */ 
/*      */   @Autowired
/*      */   private BussBillDisctCouPonPayDao bussbilldiscpayDao;
/*      */ 
/*      */   @Autowired
/*      */   private BussBillPayCheckDao bussbillpaycheckDao;
/*      */ 
/*      */   @Autowired
/*      */   private BussBillPayPosDAO bussbillPayPosDao;
/*      */ 
/*      */   @Autowired
/*      */   private MemberCashCouponDetailDAO memberCashCouponDetailDAO;
/*      */ 
/*      */   @Autowired
/*      */   private MemberCashCouponConsumeRecordDAO memberCashCouponConsumeRecordDAO;
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*      */   {
/*   99 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*      */     try {
/*  101 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, nPageIdx, 
/*  102 */         nPageSize);
/*  103 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  105 */       logger.error(e);
/*  106 */       ResponseUtils.setErrorMsgResponse(
/*  107 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/csumRqrs/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListWxOfBussInfo(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*      */   {
/*  125 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*  126 */     String openId = RequestUtils.getString(request, "openId");
/*  127 */     Long shopId = RequestUtils.getLong(request, "shopId");
/*      */     try {
/*  129 */       GsonEbRst gsonEbRst = this.dao.getGsonOfWxOfBussInfo(openId, shopId, nPageIdx, 
/*  130 */         nPageSize);
/*  131 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  133 */       logger.error(e);
/*  134 */       ResponseUtils.setErrorMsgResponse(
/*  135 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/stId/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListShopIdStId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*      */   {
/*  145 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*      */     try {
/*  147 */       int stId = 5;
/*  148 */       Map params = new HashMap();
/*  149 */       params.put("shopId", shopId);
/*  150 */       params.put("stId", Integer.valueOf(stId));
/*  151 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopIdStId(params, nPageIdx, 
/*  152 */         nPageSize);
/*  153 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  155 */       logger.error(e);
/*  156 */       ResponseUtils.setErrorMsgResponse(
/*  157 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/stId/cust/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListShopIdStIdCust(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*      */   {
/*  167 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*      */     try {
/*  169 */       int stId = 5;
/*  170 */       Map params = new HashMap();
/*  171 */       MapUtils.addToMap(params, "shopId", shopId);
/*  172 */       MapUtils.addToMap(params, "stId", Integer.valueOf(stId));
/*  173 */       MapUtils.addToMap(params, "paid", 
/*  174 */         RequestUtils.getInt(request, "paid"));
/*  175 */       MapUtils.addPercentToMap(params, "custName", 
/*  176 */         RequestUtils.getString(request, "custName"));
/*  177 */       MapUtils.addPercentToMap(params, "license", 
/*  178 */         RequestUtils.getString(request, "license"));
/*  179 */       MapUtils.addPercentToMap(params, "billNo", 
/*  180 */         RequestUtils.getString(request, "billNo"));
/*  181 */       MapUtils.addToMap(params, "createTimeStart", 
/*  182 */         RequestUtils.getDate(request, "createTimeStart"));
/*  183 */       MapUtils.addToMap(params, "createTimeEnd", 
/*  184 */         RequestUtils.getDate(request, "createTimeEnd"));
/*  185 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopIdStId(params, nPageIdx, 
/*  186 */         nPageSize);
/*  187 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  189 */       logger.error(e);
/*  190 */       ResponseUtils.setErrorMsgResponse(
/*  191 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/stId/paid/date/sum"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getSumShopIdStIdDate(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*      */   {
/*      */     try
/*      */     {
/*  206 */       Map params = new HashMap();
/*  207 */       MapUtils.addToMap(params, "shopId", shopId);
/*  208 */       MapUtils.addToMap(params, "stId", 
/*  209 */         RequestUtils.getInt(request, "stId"));
/*  210 */       MapUtils.addToMap(params, "paid", 
/*  211 */         RequestUtils.getInt(request, "paid"));
/*  212 */       MapUtils.addToMap(params, "dtPaidStart", 
/*  213 */         RequestUtils.getDate(request, "dtPaidStart"));
/*  214 */       MapUtils.addToMap(params, "dtPaidEnd", 
/*  215 */         RequestUtils.getDate(request, "dtPaidEnd"));
/*  216 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId_StId_Sum_Date(params);
/*  217 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  219 */       logger.error(e);
/*  220 */       ResponseUtils.setErrorMsgResponse(
/*  221 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"find/payHistory/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void getPayHistory(@PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize, HttpServletRequest request, HttpServletResponse response)
/*      */   {
/*  241 */     String openId = RequestUtils.getString(request, "openId");
/*      */     try {
/*  243 */       Long memberId = null;
/*  244 */       GsonEbRst gson = null;
/*  245 */       if ((shopId != null) && (StringUtils.isNotEmpty(openId))) {
/*  246 */         memberId = this.memberDAO.getMemberIdOfOpenId(openId, shopId);
/*      */ 
/*  248 */         if (memberId.longValue() > 0L) {
/*  249 */           gson = this.dao.getGsonOfAll(memberId, nPageIdx, nPageSize);
/*  250 */          }
/*  251 */         ResponseUtils.setErrorMsgResponse("您还不是会员", response);
/*  252 */         return;
/*      */       }
/*      */ 
/*  255 */       ResponseUtils.setErrorMsgResponse("获取openId失败", response);
/*  256 */       return;     } catch (SQLException e) {
/*  260 */       logger.error(e);
/*  261 */       ResponseUtils.setErrorMsgResponse(
/*  262 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/shopId/{shopId}/stId/paid/date/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListShopIdStIdDate(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*      */   {
/*  279 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*      */     try {
/*  281 */       Map params = new HashMap();
/*  282 */       MapUtils.addToMap(params, "shopId", shopId);
/*  283 */       MapUtils.addToMap(params, "saleId", RequestUtils.getLong(request, "saleId"));
/*  284 */       MapUtils.addToMap(params, "stId", RequestUtils.getInt(request, "stId"));
/*  285 */       MapUtils.addToMap(params, "paid", RequestUtils.getInt(request, "paid"));
/*  286 */       MapUtils.addToMap(params, "dtPaidStart", RequestUtils.getDate(request, "dtPaidStart"));
/*  287 */       MapUtils.addToMap(params, "dtPaidEnd", RequestUtils.getDate(request, "dtPaidEnd"));
/*  288 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId_StId_Paid_Date(params, nPageIdx, 
/*  289 */         nPageSize);
/*  290 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  292 */       logger.error(e);
/*  293 */       ResponseUtils.setErrorMsgResponse(
/*  294 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @RequestMapping(value={"find/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*      */   public void getListBussId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Integer bussId)
/*      */   {
/*      */     try
/*      */     {
/*  309 */       GsonEbRst gsonEbRst = this.dao.getGsonOfBussId(bussId);
/*  310 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*      */     } catch (SQLException e) {
/*  312 */       logger.error(e);
/*  313 */       ResponseUtils.setErrorMsgResponse(
/*  314 */         RequestUtils.getFindDataErrorMessage(request), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void insertList(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*      */   {
/*      */     try
/*      */     {
/*  332 */       int nResult = 0;
/*  333 */       Long id = null;
/*  334 */       ParserDataSetJson p = new ParserDataSetJson(
/*  335 */         request.getParameter("data"));
/*  336 */       if (p != null) {
/*  337 */         if (p.isExistsInsertRows()) {
/*  338 */           for (int i = 0; i < p.getListInsertRows().size(); ++i) {
/*  339 */             GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(i);
/*  340 */             r.autoAddHeadData("CreateTime", new Date());
/*  341 */             r.autoAddHeadData("stID", Integer.valueOf(PbPaid.getStOfId("bussBill")));
/*  342 */             r.autoAddHeadData("CreateUId", 
/*  343 */               UserSessionInfo.getIntUserIdOfRequest(request));
/*  344 */             r.autoAddHeadData("CreateUName", 
/*  345 */               UserSessionInfo.getUserNameOfRequest(request));
/*      */           }
/*      */ 
/*      */         }
/*      */ 
/*  368 */         nResult = this.dao.applyUpdates(p, "id");
/*  369 */         if ((p.isExistsInsertRows()) && (nResult > 0)) {
/*  370 */           GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(0);
/*  371 */           id = ObjectComm.objectToLong(r.getValueOfName("id"));
/*      */         }
/*      */       }
/*      */       ParserDataSetJson pCheck;
/*      */       int i;
/*      */       GsonHeadOneRow r;
/*  377 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/*  378 */         pCheck = 
/*  379 */           ParserDataSetJson.fromString(RequestUtils.getString(request, "chkPay"));
/*  380 */         if (pCheck != null) {
/*  381 */           if (pCheck.isExistsInsertRows()) {
/*  382 */             for (i = 0; i < pCheck.getListInsertRows().size(); ++i) {
/*  383 */               r = 
/*  384 */                 (GsonHeadOneRow)pCheck.getListInsertRows()
/*  384 */                 .get(i);
/*  385 */               if (id != null) {
/*  386 */                 r.autoAddHeadData("id", id);
/*      */               }
/*      */             }
/*      */           }
/*  390 */           nResult += this.bussbillpaycheckDao.applyUpdates(pCheck);
/*      */         }
/*      */       }
/*  393 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/*  394 */         pCheck = 
/*  395 */           ParserDataSetJson.fromString(RequestUtils.getString(request, "posPay"));
/*  396 */         if (pCheck != null) {
/*  397 */           if (pCheck.isExistsInsertRows()) {
/*  398 */             for (i = 0; i < pCheck.getListInsertRows().size(); ++i) {
/*  399 */               r = 
/*  400 */                 (GsonHeadOneRow)pCheck.getListInsertRows()
/*  400 */                 .get(i);
/*  401 */               if (id != null) {
/*  402 */                 r.autoAddHeadData("id", id);
/*      */               }
/*      */             }
/*      */           }
/*  406 */           nResult += this.bussbillPayPosDao.applyUpdates(pCheck);
/*      */         }
/*      */       }
/*      */ 
/*  410 */       if (nResult > 0) {
/*  411 */         DbConnection.commit();
/*  412 */         if (id != null) {
/*  413 */           String[] heads = { "id" };
/*  414 */           Object[] datas = { id };
/*  415 */           ResponseUtils.toGsonEbRst(heads, datas, response);
/*  416 */           return; }
/*  417 */         ResponseUtils.setSqlResultResponse(nResult, 
/*  418 */           RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  419 */           response);
/*      */ 
/*  421 */         return; }
/*  422 */       DbConnection.rollback();
/*  423 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  424 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  425 */         response);
/*      */     }
/*      */     catch (Exception e) {
/*  428 */       DbConnection.rollback();
/*  429 */       logger.error(e);
/*  430 */       ResponseUtils.setErrorMsgResponse(
/*  431 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/*  432 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void editList(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*      */   {
/*      */     try
/*      */     {
/*  450 */       int nResult = 0;
/*  451 */       Long id = null;
/*  452 */       ParserDataSetJson p = new ParserDataSetJson(
/*  453 */         request.getParameter("data"));
/*  454 */       if (p != null) {
/*  455 */         if (p.isExistsInsertRows()) {
/*  456 */           for (int i = 0; i < p.getListInsertRows().size(); ++i) {
/*  457 */             GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(i);
/*  458 */             r.autoAddHeadData("CreateTime", new Date());
/*  459 */             r.autoAddHeadData("stID", Integer.valueOf(PbPaid.getStOfId("bussBill")));
/*  460 */             r.autoAddHeadData("CreateUId", 
/*  461 */               UserSessionInfo.getIntUserIdOfRequest(request));
/*  462 */             r.autoAddHeadData("CreateUName", 
/*  463 */               UserSessionInfo.getUserNameOfRequest(request));
/*      */           }
/*      */ 
/*      */         }
/*      */ 
/*  486 */         nResult = this.dao.applyUpdates(p, "id");
/*  487 */         if ((p.isExistsInsertRows()) && (nResult > 0)) {
/*  488 */           GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(0);
/*  489 */           id = ObjectComm.objectToLong(r.getValueOfName("id"));
/*      */         }
/*      */       }
/*      */       ParserDataSetJson pCheck;
/*      */       int i;
/*      */       GsonHeadOneRow r;
/*  495 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/*  496 */         pCheck = 
/*  497 */           ParserDataSetJson.fromString(RequestUtils.getString(request, "chkPay"));
/*  498 */         if (pCheck != null) {
/*  499 */           if (pCheck.isExistsInsertRows()) {
/*  500 */             for (i = 0; i < pCheck.getListInsertRows().size(); ++i) {
/*  501 */               r = 
/*  502 */                 (GsonHeadOneRow)pCheck.getListInsertRows()
/*  502 */                 .get(i);
/*  503 */               if (id != null) {
/*  504 */                 r.autoAddHeadData("id", id);
/*      */               }
/*      */             }
/*      */           }
/*  508 */           nResult += this.bussbillpaycheckDao.applyUpdates(pCheck);
/*      */         }
/*      */       }
/*  511 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/*  512 */         pCheck = 
/*  513 */           ParserDataSetJson.fromString(RequestUtils.getString(request, "posPay"));
/*  514 */         if (pCheck != null) {
/*  515 */           if (pCheck.isExistsInsertRows()) {
/*  516 */             for (i = 0; i < pCheck.getListInsertRows().size(); ++i) {
/*  517 */               r = 
/*  518 */                 (GsonHeadOneRow)pCheck.getListInsertRows()
/*  518 */                 .get(i);
/*  519 */               if (id != null) {
/*  520 */                 r.autoAddHeadData("id", id);
/*      */               }
/*      */             }
/*      */           }
/*  524 */           nResult += this.bussbillpaycheckDao.applyUpdates(pCheck);
/*      */         }
/*      */       }
/*      */ 
/*  528 */       if (nResult > 0) {
/*  529 */         DbConnection.commit();
/*  530 */         if (id != null) {
/*  531 */           String[] heads = { "id" };
/*  532 */           Object[] datas = { id };
/*  533 */           ResponseUtils.toGsonEbRst(heads, datas, response);
/*  534 */           return; }
/*  535 */         ResponseUtils.setSqlResultResponse(nResult, 
/*  536 */           RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  537 */           response);
/*      */ 
/*  539 */         return; }
/*  540 */       DbConnection.rollback();
/*  541 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  542 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  543 */         response);
/*      */     }
/*      */     catch (Exception e) {
/*  546 */       DbConnection.rollback();
/*  547 */       logger.error(e);
/*  548 */       ResponseUtils.setErrorMsgResponse(
/*  549 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/*  550 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*      */   {
/*  566 */     String id = RequestUtils.getStringOfId(request);
/*      */     try {
/*  568 */       String[] strParams = id.split(",");
/*  569 */       int nResult = this.dao.deleteParams(strParams);
/*  570 */       nResult += this.bussbilldiscpayDao.deleteOfbussIds(strParams);
/*  571 */       nResult += this.bussbillpaycheckDao.deleteOfbussIds(strParams);
/*  572 */       if (nResult > 0)
/*  573 */         DbConnection.commit();
/*      */       else {
/*  575 */         DbConnection.rollback();
/*      */       }
/*  577 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  578 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/*  579 */         response);
/*      */     }
/*      */     catch (Exception e) {
/*  582 */       DbConnection.rollback();
/*  583 */       logger.error(e);
/*  584 */       ResponseUtils.setErrorMsgResponse(
/*  585 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/*  586 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"paid/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void paidCustId(HttpServletRequest request, @PathVariable("shopId") Long shopId, HttpServletResponse response)
/*      */   {
/*  603 */     String id = RequestUtils.getString(request, "id");
/*  604 */     Long userId = UserSessionInfo.getIntUserIdOfRequest(request);
/*  605 */     String userName = UserSessionInfo.getUserNameOfRequest(request);
/*  606 */     int nResult = 0;
/*      */     try {
/*  608 */       nResult = this.dao.updateBillPaidOfIds(id, userId, userName);
/*      */ 
/*  611 */       if (nResult > 0)
/*  612 */         DbConnection.commit();
/*      */       else {
/*  614 */         DbConnection.rollback();
/*      */       }
/*  616 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  617 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/*  618 */         response);
/*      */     } catch (Exception e) {
/*  620 */       DbConnection.rollback();
/*  621 */       logger.error(e);
/*  622 */       ResponseUtils.setErrorMsgResponse(
/*  623 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/*  624 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"check/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void check(HttpServletRequest request, HttpServletResponse response)
/*      */     throws SQLException
/*      */   {
/*  642 */     String id = RequestUtils.getString(request, "id");
/*  643 */     Long userId = UserSessionInfo.getIntUserIdOfRequest(request);
/*  644 */     String userName = UserSessionInfo.getUserNameOfRequest(request);
/*  645 */     int nResult = 0;
/*      */     try {
/*  647 */       nResult = this.dao.updateCheckedOfIds(userId, userName, id);
/*  648 */       if (nResult > 0)
/*  649 */         DbConnection.commit();
/*      */       else {
/*  651 */         DbConnection.rollback();
/*      */       }
/*  653 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  654 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/*  655 */         response);
/*      */     } catch (Exception e) {
/*  657 */       DbConnection.rollback();
/*  658 */       logger.error(e);
/*  659 */       ResponseUtils.setErrorMsgResponse(
/*  660 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/*  661 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   @Transactional
/*      */   @RequestMapping(value={"paid/shopId/{shopId}/member"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*      */   public void paidMember(HttpServletRequest request, HttpServletResponse response)
/*      */   {
/*  678 */     String id = RequestUtils.getString(request, "id");
/*  679 */     int nResult = 0;
/*  680 */     Long userId = UserSessionInfo.getIntUserIdOfRequest(request);
/*  681 */     String userName = UserSessionInfo.getUserNameOfRequest(request);
/*      */     try {
/*  683 */       nResult = this.dao.updateBillPaidOfIds(id, userId, userName);
/*  684 */       if (nResult > 0) {
/*  685 */         nResult = paidDetailOfbsbill(id, userId, userName, request, 
/*  686 */           response);
/*      */       }
/*  688 */       if (nResult > 0) {
/*  689 */         DbConnection.commit();
/*  690 */         ResponseUtils.setSqlResultResponse(nResult, 
/*  691 */           RequestUtils.getSqlDeleteDataErrorMessage(request), 
/*  692 */           response);
/*  693 */         return; }
/*  694 */       DbConnection.rollback();
/*  695 */       PbPaid.getResponse(nResult, response);
/*      */     }
/*      */     catch (Exception e) {
/*  698 */       DbConnection.rollback();
/*  699 */       logger.error(e);
/*  700 */       ResponseUtils.setErrorMsgResponse(
/*  701 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/*  702 */         e.getMessage(), response);
/*      */     }
/*      */   }
/*      */ 
/*      */   private int paidDetailOfbsbill(String id, Long userId, String userName, HttpServletRequest request, HttpServletResponse response)
/*      */     throws SQLException, Exception
/*      */   {
/*  709 */     Long bissId = Long.valueOf(id);
/*  710 */     int nResult = 0;
/*  711 */     String memo = "";
/*  712 */     GsonHeadOneRow r = this.dao.getGsonHeadOneRowOfBsbillIds(bissId);
/*  713 */     if (r != null) {
/*  714 */       Long shopId = (Long)r.getValueOfName("shopId");
/*  715 */       Long memberId = (Long)r.getValueOfName("memberId");
/*  716 */       String billNo = (String)r.getValueOfName("billNo");
/*  717 */       Double billAmt = ObjectComm.objectToDouble(
/*  718 */         r.getValueOfName("BillAmt"), Integer.valueOf(0));
/*  719 */       String memo1 = (String)r.getValueOfName("Memo");
/*  720 */       if (memo1 != null) {
/*  721 */         memo = memo1;
/*      */       }
/*  723 */       Double dDeposit = Double.valueOf(0.0D);
/*  724 */       Double dIntAmt = Double.valueOf(0.0D);
/*  725 */       Double dCach = Double.valueOf(0.0D);
/*  726 */       Double payCashMny = Double.valueOf(0.0D);
/*  727 */       Double payDisctCoup = Double.valueOf(0.0D);
/*  728 */       CustMessage csMsg = new CustMessage();
/*  729 */       if (ObjectComm.objectToDouble(r.getValueOfName("ReceAmt"), Integer.valueOf(0)).doubleValue() == 0.0D) {
/*  730 */         this.memberLogDAO.insertMemberLogBuss(MemberActConst.PAID, billNo, 
/*  731 */           dIntAmt, dDeposit, dCach, dCach, memberId, userId, 
/*  732 */           userName);
/*  733 */         return 1;
/*      */       }
/*  735 */       Integer stId = ObjectComm.objectToInteger(r.getValueOfName("stID"), 
/*  736 */         Integer.valueOf(0));
/*  737 */       Double payDisct = ObjectComm.objectToDouble(
/*  738 */         r.getValueOfName("PayDisctCoup"), Integer.valueOf(0));
/*  739 */       Integer payIntAmt = ObjectComm.objectToInteger(
/*  740 */         r.getValueOfName("PayIntAmt"), Integer.valueOf(0));
/*  741 */       Double payCash = ObjectComm.objectToDouble(
/*  742 */         r.getValueOfName("PayCash"), Integer.valueOf(0));
/*  743 */       Double payDepstAmt = ObjectComm.objectToDouble(
/*  744 */         r.getValueOfName("PayDepstAmt"), Integer.valueOf(0));
/*  745 */       Double payCheck = ObjectComm.objectToDouble(
/*  746 */         r.getValueOfName("PayCheck"), Integer.valueOf(0));
/*  747 */       Double payCredit = ObjectComm.objectToDouble(
/*  748 */         r.getValueOfName("PayCredit"), Integer.valueOf(0));
/*  749 */       if ((payCredit != null) && (payCredit.doubleValue() > 0.0D)) {
/*  750 */         this.memberLogDAO.insertMemberLogBuss(MemberActConst.PAID, billNo, 
/*  751 */           dIntAmt, dDeposit, dCach, dCach, memberId, userId, 
/*  752 */           userName);
/*  753 */         return 1;
/*      */       }
/*  755 */       Double payPersonCard = ObjectComm.objectToDouble(
/*  756 */         r.getValueOfName("PayPersonCard"), Integer.valueOf(0));
/*  757 */       Double payPos = ObjectComm.objectToDouble(
/*  758 */         r.getValueOfName("PayPos"), Integer.valueOf(0));
/*      */ 
/*  760 */       Double payCashCoupAmtMny = ObjectComm.objectToDouble(
/*  761 */         r.getValueOfName("PayCashCoupAmt"), Integer.valueOf(0));
/*  762 */       if ((payIntAmt != null) && (payIntAmt.intValue() != 0)) {
/*  763 */         dIntAmt = Double.valueOf(dIntAmt.doubleValue() + payIntAmt.intValue());
/*      */       }
/*  765 */       if ((payDepstAmt != null) && (payDepstAmt.doubleValue() != 0.0D)) {
/*  766 */         dDeposit = Double.valueOf(dDeposit.doubleValue() + payDepstAmt.doubleValue());
/*      */       }
/*  768 */       if ((payCash != null) && (payCash.doubleValue() != 0.0D)) {
/*  769 */         dCach = Double.valueOf(dCach.doubleValue() + payCash.doubleValue());
/*      */       }
/*  771 */       if ((payCheck != null) && (payCheck.doubleValue() != 0.0D)) {
/*  772 */         dCach = Double.valueOf(dCach.doubleValue() + payCheck.doubleValue());
/*      */       }
/*      */ 
/*  777 */       if ((payPersonCard != null) && (payPersonCard.doubleValue() != 0.0D)) {
/*  778 */         dCach = Double.valueOf(dCach.doubleValue() + payPersonCard.doubleValue());
/*      */       }
/*  780 */       if ((payPos != null) && (payPos.doubleValue() != 0.0D)) {
/*  781 */         dCach = Double.valueOf(dCach.doubleValue() + payPos.doubleValue());
/*      */       }
/*  783 */       if ((payCashCoupAmtMny != null) && (payCashCoupAmtMny.doubleValue() != 0.0D)) {
/*  784 */         payCashMny = Double.valueOf(payCashMny.doubleValue() + payCashCoupAmtMny.doubleValue());
/*      */       }
/*  786 */       if ((payDisct != null) && (payDisct.doubleValue() != 0.0D))
/*  787 */         payDisctCoup = Double.valueOf(payDisctCoup.doubleValue() + payDisct.doubleValue());
/*      */       GsonHeadManyRows detailIDsRslt;
/*      */       int i;
/*      */       
/*      */       Long detailId;
/*  796 */       if (dIntAmt.doubleValue() > 0.0D) {
/*  797 */         detailIDsRslt = this.integralDetailDAO
/*  798 */           .getSelectMemIntDtialRslt(memberId, shopId);
/*  799 */         if ((detailIDsRslt != null) && (detailIDsRslt.getDataLength() > 0)) {
/*  800 */           Integer memberIntegral = Integer.valueOf(0);
/*  801 */           for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/*  802 */             Integer intAmtTemp = (Integer)detailIDsRslt
/*  803 */               .getValueOfName("Integral", i);
/*  804 */             memberIntegral = Integer.valueOf(memberIntegral.intValue() + intAmtTemp.intValue());
/*      */           }
/*  806 */           if (memberIntegral.intValue() >= dIntAmt.doubleValue()) {
/*  807 */             Integer tempIntAmt = Integer.valueOf(dIntAmt.intValue());
/*  808 */             boolean decIntAmt = true;
/*  809 */             for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/*  810 */               Integer intAmt = (Integer)detailIDsRslt
/*  811 */                 .getValueOfName("Integral", i);
/*  812 */               detailId = (Long)detailIDsRslt
/*  813 */                 .getValueOfName("DetailID", i);
/*  814 */               Integer intLog = Integer.valueOf(0);
/*  815 */               if (tempIntAmt.intValue() - intAmt.intValue() < 0) {
/*  816 */                 intLog = tempIntAmt;
/*      */               }
/*  818 */               tempIntAmt = Integer.valueOf(tempIntAmt.intValue() - intAmt.intValue());
/*  819 */               if (!(decIntAmt)) break;
/*  820 */               if (tempIntAmt.intValue() >= 0)
/*      */               {
/*  822 */                 nResult = nResult + this.integralDetailDAO
/*  822 */                   .updateIntAmtDtlStatusOfID(
/*  823 */                   memberId, detailId);
/*      */ 
/*  825 */                 nResult = nResult + this.integralConsumeRecordDAO
/*  825 */                   .insertIntgCrIt(detailId, billNo, 
/*  826 */                   intAmt, bissId, memo);
/*  827 */                 if (tempIntAmt.intValue() == 0)
/*  828 */                   decIntAmt = false;
/*      */               }
/*      */               else {
/*  831 */                 intAmt = Integer.valueOf(intAmt.intValue() - intLog.intValue());
/*      */ 
/*  833 */                 nResult = nResult + this.integralDetailDAO
/*  833 */                   .updateIntAmtMemberIt(intAmt, 
/*  834 */                   memberId, detailId);
/*      */ 
/*  836 */                 nResult = nResult + this.integralConsumeRecordDAO
/*  836 */                   .insertIntgCrIt(detailId, billNo, 
/*  837 */                   intLog, bissId, memo);
/*  838 */                 decIntAmt = false;
/*      */               }
/*      */ 
/*      */             }
/*      */ 
/*  844 */             Integer sum = 
/*  845 */               Integer.valueOf(this.integralDetailDAO
/*  845 */               .selectIntAmtTotal(memberId));
/*  846 */             nResult += this.memberDAO.updateMemberIntAmt(sum, memberId);
/*  847 */             }
/*  848 */           return -1;
/*      */         }
/*      */ 
/*  852 */         return -4;
/*      */       }
/*      */ 
/*  857 */       if (payCashMny.doubleValue() > 0.0D) {
/*  858 */         label1023: detailIDsRslt = this.memberCashCouponDetailDAO
/*  859 */           .getSelectCashCouponDtialRslt(memberId, shopId);
/*  860 */         if ((detailIDsRslt != null) && (detailIDsRslt.getDataLength() > 0)) {
/*  861 */           Double memberCashCpon = Double.valueOf(0.0D);
/*  862 */           for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/*  863 */             Double cashCponTemp = 
/*  864 */               ObjectComm.objectToDouble(detailIDsRslt.getValueOfName(
/*  865 */               "FaceValue", i), Integer.valueOf(0));
/*  866 */             memberCashCpon = Double.valueOf(memberCashCpon.doubleValue() + cashCponTemp.doubleValue());
/*      */           }
/*  868 */           if (memberCashCpon.doubleValue() >= payCashMny.doubleValue()) {
/*  869 */             Double tempCashCpon = payCashMny;
/*  870 */             boolean decCashCpon = true;
/*  871 */             for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/*  872 */               Double cashCpon = ObjectComm.objectToDouble(
/*  873 */                 detailIDsRslt
/*  874 */                 .getValueOfName("FaceValue", i), Integer.valueOf(0));
/*  875 */               detailId = (Long)detailIDsRslt
/*  876 */                 .getValueOfName("DetailID", i);
/*  877 */               Double cashLog = Double.valueOf(0.0D);
/*  878 */               if (tempCashCpon.doubleValue() - cashCpon.doubleValue() < 0.0D) {
/*  879 */                 cashLog = tempCashCpon;
/*      */               }
/*  881 */               tempCashCpon = Double.valueOf(tempCashCpon.doubleValue() - cashCpon.doubleValue());
/*  882 */               if (!(decCashCpon)) break;
/*  883 */               if (tempCashCpon.doubleValue() >= 0.0D)
/*      */               {
/*  885 */                 nResult = nResult + this.memberCashCouponDetailDAO
/*  885 */                   .updateCashCouponDtlStatusOfID(
/*  886 */                   memberId, detailId);
/*      */ 
/*  888 */                 nResult = nResult + this.memberCashCouponConsumeRecordDAO
/*  888 */                   .insertCashConpConsum(detailId, 
/*  889 */                   billNo, cashCpon, bissId, 
/*  890 */                   memo);
/*  891 */                 if (tempCashCpon.doubleValue() == 0.0D)
/*  892 */                   decCashCpon = false;
/*      */               }
/*      */               else {
/*  895 */                 cashCpon = Double.valueOf(cashCpon.doubleValue() - cashLog.doubleValue());
/*      */ 
/*  897 */                 nResult = nResult + this.memberCashCouponDetailDAO
/*  897 */                   .updateCashCouponMemberCs(cashCpon, 
/*  898 */                   memberId, detailId);
/*      */ 
/*  900 */                 nResult = nResult + this.memberCashCouponConsumeRecordDAO
/*  900 */                   .insertCashConpConsum(detailId, 
/*  901 */                   billNo, cashLog, bissId, 
/*  902 */                   memo);
/*  903 */                 decCashCpon = false;
/*      */               }
/*      */ 
/*      */             }
/*      */ 
/*  910 */             Double sum = this.memberCashCouponDetailDAO
/*  911 */               .selectSqlCashCouponDtlSum(memberId);
/*  912 */             nResult = this.memberDAO.updateMemberCashCoup(sum, memberId);
/*  913 */            }
/*  914 */           return -3;
/*      */         }
/*      */ 
/*  917 */         return -6;
/*      */       }
/*      */ 
/*  921 */       if (dDeposit.doubleValue() > 0.0D)
/*      */       {
/*  923 */         label1396: nResult = nResult + 
/*  923 */           PbPaid.getPositDeposit(dDeposit, memberId, billNo, 
/*  923 */           shopId, bissId, memo);
/*  924 */         if (nResult < 0)
/*  925 */           return nResult;
/*      */       }
/*      */       CSessionUser sessionUser;
/*  930 */       if (dCach.doubleValue() > 0.0D) {
/*  931 */         nResult += this.memberDAO.updateMemberInc(memberId, dCach);
/*  932 */         sessionUser = 
/*  933 */           UserSessionInfo.user_getUserOfRequest(request);
/*      */ 
/*  935 */         nResult = nResult + 
/*  935 */           PbPaid.getGivePresent(sessionUser, dCach, id, 
/*  935 */           memberId, stId, Boolean.valueOf(true), memo);
/*  936 */         if (nResult < 0) {
/*  937 */           return nResult;
/*      */         }
/*      */ 
/*      */       }
/*      */ 
/*  943 */       if (dIntAmt.doubleValue() < 0.0D) {
/*  944 */         int nrst = 0;
/*  945 */         nrst = 
/*  946 */           PbPaid.getNtiveIntegral(bissId, dIntAmt.intValue(), memo);
/*  947 */         if (nrst < 0)
/*  948 */           return nrst;
/*  949 */         if ((nrst == 0) || (nrst > 0)) {
/*  950 */           nResult += nrst;
/*      */         }
/*      */ 
/*      */       }
/*      */ 
/*  955 */       if (payCashMny.doubleValue() < 0.0D) {
/*  956 */         nResult += PbPaid.getNtiveCashConp(bissId, payCashMny, memo);
/*  957 */         if (nResult < 0) {
/*  958 */           return -7;
/*      */         }
/*      */ 
/*      */       }
/*      */ 
/*  963 */       if (dDeposit.doubleValue() < 0.0D)
/*      */       {
/*  965 */         nResult = nResult + 
/*  965 */           PbPaid.getNtiveDopsit(dDeposit, memberId, billNo, 
/*  965 */           shopId, userName, bissId, memo);
/*  966 */         if (nResult < 0) {
/*  967 */           return nResult;
/*      */         }
/*      */ 
/*      */       }
/*      */ 
/*  972 */       if (dCach.doubleValue() < 0.0D) {
/*  973 */         nResult += PbPaid.getNtiveCash(memberId, dCach, shopId);
/*  974 */         sessionUser = 
/*  975 */           UserSessionInfo.user_getUserOfRequest(request);
/*      */ 
/*  977 */         nResult = nResult + 
/*  977 */           PbPaid.getGivePresent(sessionUser, dCach, id, 
/*  977 */           memberId, stId, Boolean.valueOf(true), memo);
/*  978 */         if (nResult < 0) {
/*  979 */           return nResult;
/*      */         }
/*      */       }
/*      */ 
/*  983 */       GsonHeadOneRow pa = this.memberDAO.getPaidOneRowOfMemberId(memberId);
/*  984 */       if ((pa != null) && (pa.getDataLength() > 0)) {
/*  985 */         String sData = "data=" + pa.objectToJsonStr() + 
/*  986 */           "&" + "id" + "=" + memberId;
/*  987 */         String sUrl = "ptmember/editPaid";
/*  988 */         GsonEbRst rst = HttpGsonPtResponseUtils.postPtEbRst(sUrl, 
/*  989 */           sData, response);
/*  990 */         if ((rst == null) || (rst.getState() != 0))
/*  991 */           return -14;
/*      */       }
/*      */       else {
/*  994 */         return -14;
/*      */       }
/*      */ 
/*  997 */       Object custId = r.getValueOfName("CustId");
/*  998 */       String custName = (String)r.getValueOfName("CustName");
/*  999 */       csMsg.setBillAmt(billAmt);
/* 1000 */       csMsg.setBussId(bissId);
/* 1001 */       csMsg.setStId(stId);
/* 1002 */       csMsg.setCustId(custId);
/* 1003 */       csMsg.setCustName(custName);
/* 1004 */       csMsg.setIntAmt(ObjectComm.objectToInteger(dIntAmt, Integer.valueOf(0)));
/* 1005 */       csMsg.setDeposit(dDeposit);
/* 1006 */       csMsg.setCashConp(payCashMny);
/* 1007 */       csMsg.setShopId(shopId);
/* 1008 */       csMsg.setCash(dCach);
/* 1009 */       csMsg.setDpsitConp(payDisctCoup);
/* 1010 */       csMsg.setkCashConp(ObjectComm.objectToDouble(
/* 1011 */         pa.getValueOfName("CashCouponAmount"), Integer.valueOf(0)));
/* 1012 */       csMsg.setkDeposit(ObjectComm.objectToDouble(
/* 1013 */         pa.getValueOfName("DepositAmount"), Integer.valueOf(0)));
/* 1014 */       csMsg.setkDpsitConp(ObjectComm.objectToDouble(
/* 1015 */         pa.getValueOfName("CouponAmount"), Integer.valueOf(0)));
/* 1016 */       csMsg.setkIntAmt(ObjectComm.objectToInteger(
/* 1017 */         pa.getValueOfName("IntegralAmount"), Integer.valueOf(0)));
/* 1018 */       csMsg.setMp((String)r.getValueOfName("Mp"));
/* 1019 */       csMsg.setCrTime(new Date());
/* 1020 */       nResult += PbPaid.sendSMS(csMsg);
/* 1021 */       if (nResult < 0) {
/* 1022 */         return -16;
/*      */       }
/* 1024 */       this.memberLogDAO
/* 1025 */         .insertMemberLogBuss(MemberActConst.PAID, billNo, dIntAmt, 
/* 1026 */         dDeposit, dCach, dCach, memberId, userId, userName);
/*      */     }
/* 1028 */     return nResult;
/*      */   }
/*      */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.bussBill.bussBill.controller.BussBillController
 * JD-Core Version:    0.5.3
 */